package cn.bb.springboothello.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
/*
* springboot 整合filter方式1
* <filter>
 *     <filter-name>FirstServlet</filter-name>
 *     <filter-class>cn.bb.springboothello.filter.FirstFilter</filter-class>
 * </filter>
 *
 *
 * <filter-mapping>
 *     <filter-name>FirstFilter</servlet-name>
 *     <url-pattern>/first</url-pattern>
 * </filter-mapping>
* */
//@WebFilter(filterName = "FirstFilter",urlPatterns = {"*.do","*.jsp"})//多个时URL后面跟的是一个数组
@WebFilter(filterName = "FirstFilter",urlPatterns = "/first")
public class FirstFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("进入Filter");
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("离开Filter");
    }

    @Override
    public void destroy() {

    }
}
